#ifndef APPLICATIONINFO_H
#define APPLICATIONINFO_H

#include <QtCore/QObject>
#include <QtQml/QQmlPropertyMap>
#include <QSortFilterProxyModel>

class ApplicationInfo : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QString dpi READ dpi NOTIFY dpiChanged)
    Q_PROPERTY(qreal ratio READ ratio NOTIFY ratioChanged)

    Q_PROPERTY(QObject *colors READ colors CONSTANT)
    Q_PROPERTY(QObject *constants READ constants CONSTANT)

    Q_PROPERTY(bool isPortraitMode READ isPortraitMode WRITE setIsPortraitMode NOTIFY portraitModeChanged)
    Q_PROPERTY(int applicationWidth READ applicationWidth WRITE setApplicationWidth NOTIFY applicationWidthChanged)

public:
    explicit ApplicationInfo(QObject *parent = 0);

    QString dpi() const { return m_dpi; }
    qreal ratio() const { return m_ratio; }
    QQmlPropertyMap *colors() const { return m_colors; }
    QQmlPropertyMap *constants() const { return m_constants; }
    bool isPortraitMode() const { return m_isPortraitMode; }
    inline void setIsPortraitMode(const bool newMode)
    {
        if (newMode != m_isPortraitMode)
        {
            m_isPortraitMode = newMode;
            emit portraitModeChanged();
        }
    }

    int applicationWidth() const { return m_applicationWidth; }
    inline void setApplicationWidth(const int newWidth)
    {
        if (newWidth != m_applicationWidth)
        {
            m_applicationWidth = newWidth;
            emit applicationWidthChanged();
        }
    }

signals:
    void dpiChanged();
    void ratioChanged();
    void portraitModeChanged();
    void applicationWidthChanged();

    //===================== for main page ================================
    void showMainPage();

public slots:
    void initData();

private:
    bool m_isMobile;
    QString m_dpi;
    qreal m_ratio;
    QQmlPropertyMap * m_colors;
    QQmlPropertyMap * m_constants;
    bool m_isPortraitMode;
    int m_applicationWidth;

private:
    void initSignalSlots(void);
    void breakSignalSlots(void);

};

#endif // APPLICATIONINFO_H
